//
//  EmojiAttachment.m
//  YunShouHu
//
//  Created by WangQiang on 16/6/23.
//  Copyright © 2016年 WangQiang. All rights reserved.
//

#import "EmojiAttachment.h"

@implementation EmojiAttachment
-(instancetype)initWithEmotion:(EmojiEmotion *)emotion{
    if(self = [super init]){
        _emoji = emotion;
        if(_emoji.pngName.length <= 0){
            self.image = nil;
            self.bounds = CGRectZero;
        }else{
            self.image = [UIImage imageNamed:_emoji.pngName];
            self.bounds = CGRectMake(0, 0, 24.0, 24.0);
        }
    }
    return self;
}
+(instancetype)emojiAttachmentWithEmotion:(EmojiEmotion *)emotion{
    return [[self alloc] initWithEmotion:emotion];
}
+(NSAttributedString *)emojiAttachmentAttributeStringWithEmotion:(EmojiEmotion *)emotion{
    return [NSAttributedString attributedStringWithAttachment:[self emojiAttachmentWithEmotion:emotion]];
}
@end
